package com.xiezc.springboot_dht.util;

import com.xiezc.springboot_dht.entityx.Node;
import com.xiezc.springboot_dht.entityx.RouterTable;
import com.xiezc.springboot_dht.message.Message;
import com.xiezc.springboot_dht.model.BeString;

import java.net.InetSocketAddress;
import java.nio.charset.Charset;
import java.util.concurrent.BlockingQueue;
import java.util.concurrent.LinkedBlockingQueue;

/**
 * @author wb-xzc291800
 * @date 2018/04/27 14:30
 */
public interface Const {
    Charset defaultCharset = Charset.forName("utf8");

    /**
     * 工作的端口
     */
    int worlkPort = 9000;

    BeString thisId = new BeString(XUtil.SHA1("dhtSpider").substring(20));

    RouterTable routerTable = new RouterTable();

    BlockingQueue<Message> sendCache = new LinkedBlockingQueue<>();
    BlockingQueue<Message> recvCache = new LinkedBlockingQueue<>();

    Node myNode = Node.createNode(thisId, new InetSocketAddress("127.0.0.1", worlkPort));

    /**
     * 从队列中获得数据的阻塞时间
     */
    int cachePollSec = 3 * 60;
    /**
     * ｔｏｋｅｎ的时效
     */
    int tokenLievMin = 10;

    /**
     * 每个node的超时时间的设置
     */
    long deadNodeTimeSec = 10 * 60 * 1000;

    /**
     * 每个KBucket的最大容量
     */
    int KBucketSize = 20;

    int receviceDataLen = 512 * 1024;

}
